﻿#pragma once

#include "../graphic/GameplayView.h"

#include <boost/signal.hpp>
#include <boost/tuple/tuple.hpp>
#include "../../helpers/server/gameplay/PlayerMenu.h"
#include "../../helpers/server/gameplay/PickPlayersDialog.h"
#include "../../helpers/graphic/gameplay/GameEnd.h"
#include "../../../utils/gui/Form.h"
#include "../../../domain/models/CardSet.h"
#include "../../../domain/models/Player.h"
#include "../../../domain/network/GameServer.h"
#include "../../../domain/network/PlayerClient.h"


namespace Views {
	namespace Server {
		class GameplayView: public Views::Graphic::GameplayView
		{
			boost::signals::connection newConnectionConnection;

			Helpers::Server::Gameplay::PlayerMenu* player_menu;
			Helpers::Server::Gameplay::PickPlayersDialog* pick_players_dialog;
			Utils::GUI::Button* PlayerInfo;
			Domain::Network::GameServer* server;

			Cards::PlayersCards players_cards;

			std::vector<std::pair<Cards::PlayerCard*, Domain::Network::GameClient*>> players;
		public:
			GameplayView(Utils::GUI::Form*, Domain::Network::GameServer*);

			virtual void startTurn(Players::Player*);
			virtual void endTurn(Players::Player*);
			virtual void openPickPlayersDialog(Cards::PlayersCards players_cards);
			virtual void playerLose(Players::Player*);
			virtual void playerWin(Players::Player*);

		protected:
			void connectPlayer(Domain::Network::GameClient*);
			void onPlayersConfirm();
			virtual void onPlayerLoseDialogClose();
			virtual void onPlayerWinDialogClose();
			virtual Domain::Network::GameServer::OnReceiveData onPlayerLoseDialogClose;
			virtual Domain::Network::GameServer::OnReceiveData onPlayerWinDialogClose;
		};
	}
}

